<template>
    <view class="content">

        <!-- 		<view class="cu-form-group">
				<view class="title">客户名称</view>
				<input placeholder="请输入客户名称" name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">客户来源</view>
				<picker @change="sourcePicker" :value="index" :range="picker">
					<view class="picker">
						{{index>-1?picker[index]:'请选择客户来源'}}
					</view>
				</picker>
			</view> -->
        <view class="cu-form-group">
            <view class="title">姓名</view>
            <input v-model="form.name" placeholder="请输入姓名" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">手机</view>
            <input v-model="form.mobile" type="number" placeholder="请输入手机号" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">电话</view>
            <input v-model="form.telephone" type="number" placeholder="请输入电话号" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">邮箱</view>
            <input v-model="form.email" placeholder="请输入邮箱" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">部门</view>
            <input v-model="form.dept" placeholder="请输入部门" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">职务</view>
            <input v-model="form.post" placeholder="请输入职务" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">地址</view>
            <input v-model="form.address" placeholder="请输入地址" name="input"></input>
        </view>
        <view class="cu-form-group">
            <view class="title">备注</view>
            <input v-model="form.remark" placeholder="请输入备注" name="input"></input>
        </view>
        <!-- <view class="cu-form-group">
				<view class="title">客户行业</view>
				<picker @change="sourcePicker" :value="index" :range="picker">
					<view class="picker">
						{{index>-1?picker[index]:'请选择客户行业'}}
					</view>
				</picker>
			</view>
			<view class="cu-form-group">
				<view class="title">客户级别</view>
				<picker @change="sourcePicker" :value="index" :range="picker">
					<view class="picker">
						{{index>-1?picker[index]:'请选择客户级别'}}
					</view>
				</picker>
			</view> -->
        <view class="btn-box">
            <view class="submit-btn" @click="submit">保存</view>
        </view>

    </view>
</template>

<script>
    import api from '@/api/api.js';
    export default {
        data() {
            return {
                form: {
                    customerId: undefined,
                    name: undefined,
                    mobile: undefined,
                    email: undefined,
                    dept: undefined,
                    post: undefined,
                    address: undefined,
                    remark: undefined,
                }
            }
        },
        onLoad(options) {
            this.form.customerId = options.customerId;
            // 修改顶部导航背景色
            uni.setNavigationBarColor({
                frontColor: '#ffffff',
                backgroundColor: '#39b54a',
                animation: {
                    duration: 400,
                    timingFunc: 'easeIn'
                }
            })
        },
        methods: {
            submit() {
                if (this.utils.isEmpty(this.form.name)) {
                    uni.showToast({
                        title: "请输入姓名",
                        icon: 'none',
                    });
                    return
                }
                if (this.utils.isEmpty(this.form.mobile)) {
                    uni.showToast({
                        title: "请输入手机号",
                        icon: 'none',
                    });
                    return
                }
                api.addContact(this.form).then(
                    res => {
                        if (res.code == 200) {
                            uni.showToast({
                                title: '提交成功',
                                duration: 2000
                            });
                            setTimeout(function() {
                                uni.navigateBack({
                                    success: () => {}
                                })
                            }, 500);
                        } else {
                            uni.showToast({
                                title: res.msg,
                                icon: 'none',
                            });
                        }

                    },
                    rej => {}
                );

            }
            // 客户来源
            // sourcePicker(e) {
            // 	this.index = e.detail.value
            // },
        }
    }
</script>

<style scoped lang="scss">
    .content {
        margin-top: 20upx;

        .floow-cont {
            flex-direction: column;
            background-color: #ffffff;
            padding: 1rpx 30rpx;
            margin-top: 20upx;

            .title {
                text-align: justify;
                padding-right: 30upx;
                font-size: 30upx;
                position: relative;
                height: 60upx;
                line-height: 60upx;
            }

        }
    }

    .btn-box {
        padding: 20upx 24upx;

        .submit-btn {
            height: 80upx;
            line-height: 80upx;
            text-align: center;
            font-size: 28upx;
            color: #fff;
            border-radius: 8upx;
            background: #39b54a;
        }
    }
</style>